package cn.imokay.springboot.yml.configmodel;

//import cn.imokay.springboot.yml.entity.School;
import cn.imokay.springboot.yml.entity.User;
import lombok.Data;
import org.hibernate.validator.constraints.Email;
import org.hibernate.validator.constraints.NotBlank;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.Valid;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

@Data
@Configuration
@ConfigurationProperties("myconfig")
@Validated
public class ConfigValidateModel {
   @Email
   @NotNull
   private String email;

   @Max(35)
   private int age;

   @Valid
   //此处如果没有new关键字初始化,school对象会是null,确认是内部类的问题,因为改成外部类就可以不用new关键字初始化
   private School school = new School();

   @Data
   public class School{
      @NotNull
      private String name;
      //@NotNull
      private String addr;
   }
}
